<template>
	<view class="">
		<common-title :title="titleContent" @clickLeft="backToUpPage"></common-title>
		<view class="">
			<!-- 我的余额 -->
			<view class="balance">
				<view class="my-balance">我的余额</view>
				<view class="money">{{userBalance.balance}}<image src="../../../static/images/mine/coin.png" mode="aspectFill"/></view>
			</view>
			<!-- 消费记录 -->
			<view class="bill-details">
				<view class="bill">消费记录</view>
				<view class="details">敬请期待</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref, onMounted } from "vue";
	import { getUserBalance } from "../../../utils/apiMine";
	//================================common-title=========================================
	//标题内容
	const titleContent = ref({
		left:'返回',
		midst:'硬币包'
	});
	
	//返回
	const backToUpPage = () => {
		uni.switchTab({
			url:'/pages/mine/mine'
		})
	};
	//---------------------------------onMounted---------------------------------------------
	const userBalance = ref({
		'balance':0
	})
	onMounted( async () => {
		await getUserBalance().then((res) => {
			// console.log(res);
			userBalance.value = res;
		})
	})
</script>

<style lang="scss" scoped>
	.balance{
		width: 750rpx;
		height: 120px;
		background: linear-gradient(to right, rgba(240, 240, 240, 1), rgba(211, 211, 211, 1));
		position: relative; /* .balance 需要为相对定位 */
		.my-balance{
			position: relative;
			top: 10px;
			left: 20px;
			font-size: 22px;
			font-weight: 100;
		}
		.money{
			position: absolute; /* 使用绝对定位 */
			bottom: 10px; /* 距离底部 10px */
			right: 20px; /* 距离右侧 20px */
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28px;
			font-weight: bold;
			image{
				width: 40px;
				height: 40px;
				margin-left: 10px;
			}
		}
	}
	.bill-details{
		.bill{
			padding: 5px;
			border-bottom: 1px solid #ccc; /* 设置底部边框为 1px 的实线，颜色为浅灰色 */
		}
		.details{
			
		}
	}
</style>